import {
  aesEncrypt
} from '@/utils/encrypt'

export function generateSign(key, code) {
  const timestamp = generateUnixTimestamp()
  const signData = JSON.stringify({
    appCode: code,
    unixTimestamp: timestamp
  })
  return aesEncrypt(signData, key)
}

function generateUnixTimestamp() {
  return Math.round(new Date().getTime() / 1000)
}
